package com.joysuch.wwyt.dynamicdata;

import com.joysuch.wwyt.dynamicdata.enums.ProcessorSelector;
import com.joysuch.wwyt.dynamicdata.processor.*;
import com.joysuch.wwyt.dynamicdata.processor.DynamicDataExportProcessor;

/**
 * <p>
 * The factory to create processor
 * </p>
 *
 * @author jwk
 * @since 2021-11-30
 */
public class DynamicProcessorSelector {
    /**
     * write processor
     * @param selector
     * @return
     */
    public IDynamicDataProcessor select(String selector) {
        IDynamicDataProcessor processor;
        switch (ProcessorSelector.find(selector)) {
            case INSERT:
                processor = new DynamicDataInsertProcessor();
                break;
            case UPDATE:
                processor = new DynamicDataUpdateProcessor();
                break;
            case EXPORT:
                processor = new DynamicDataExportProcessor();
                break;
            case IMPORT:
                processor = new DynamicDataImportProcessor();
                break;
            case SELECT:
                processor = new DynamicDataSelectProcessor();
                break;
            default:
                throw new RuntimeException("Processor select does not exist");
        }
        return processor;
    }
}
